/*
 * Group 3, User Interface Programming II (vt11)
 * Pooya | Flora | Monica | Can
 */
package vical.view.model;

import java.util.Calendar;

/**
 * The model for the Time Line. Responsible for all parameters of TimeLine.
 * @author Can
 */
public class TimeLineModel {

    private final int hours = 24;
    private final int hourSpaceV = 60;
    private final int spaceBeginning = 10;
    private final int spaceEndding = 10;

    public TimeLineModel() {
    }

    public int getHours() {
        return hours;
    }

    // the hour is from 0 to 24
    public int getTimePositionY(int hour) {
        if (hour == 0) {
            return spaceBeginning;
        }
        return hour * hourSpaceV + spaceBeginning;
    }
    
    public int getTimePositionY(Calendar cal) {
        int hour = cal.get(Calendar.HOUR);
        int min = cal.get(Calendar.MINUTE);
        if (cal.get(Calendar.AM_PM) == Calendar.PM) {
            hour += 12;
        }
        return getTimePositionY(hour) + (min*hourSpaceV)/60;
    }
    
    public int getTotalLength() {
        return spaceBeginning + hours * hourSpaceV + spaceEndding;
    }
}
